<?php
/* @var $this OrderController */
Yii::app()->clientScript->registerCoreScript('jquery');
Yii::app()->clientScript->registerCoreScript(Yii::app()->baseUrl.'/js/common.js');
Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl.'/css/style/style_cart.css');
Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl.'/css/style/style_two.css');
$this->breadcrumbs=array(
	'订单'=>array('/member/order'),
	'确认订单',
);
?>

<div class="steps">
    <ul class="fs_14 fw_b c_666 c_f">
        <li class="done done_a first"><span class="one">1.查看购物车</span></li>
        <li class="cur"><span class="two">2.确认订单信息</span></li>
        <li class=""><span class="three">3.付款</span></li>
        <li class=""><span class="four">4.确认收货</span></li>
        <li class="last"><span class="five">5.评价</span></li>
    </ul>
</div>
<div class="hr_25"></div>
<form method="post" action="/member/order/SaveOrder" id="addressFrm">
<!--确认收货地址  start-->
<div class="conf_address">
		<div class="hd"><h2 class="fs_14">确认收货地址</h2></div>
    <div class="hr_18"></div>
    <div class="bd" id="addressList">
    	<?php 
    	$sql = new CDbCriteria(array(
                    'condition' => 'zm_id = ' . Yii::app()->user->userid,                    
                ));
        $items = MemAddres::model()->findAll($sql);      
        if ($items) { 
        ?>
        <div class="address_list c_f">
            <ul>                       
        <?php  foreach ($items as $i) {                          
                ?>
                <?php if(!empty($addid)){?>
                 <li<?php if ($i->zma_id == $addid) {?> class="select"<?php }?>>
                    <?php echo CHtml::link('修改本地址',array('/member/index/addaddress','aid'=>$i->zma_id),array('class'=>'modify f_r c_06c click','target'=>'_black'))?>
                    <?php if ($i->zma_default == 1) {?><span class="c_999 f_r">（默认地址）</span><?php }?>
                    <input class="radio" type="radio" name="order[address]" <?php if ($i->zma_id == $addid) {?>checked="checked"<?php }?> value ="<?php echo $i->zma_id ?>"  />
                    <label><span><?php echo Area::model()->getAreaStrByFloorId($i->zar_id)?><?php echo $i->zma_address?></span> <em>( <?php echo $i->zma_name?> 收 )  <?php echo $i->zma_mob?></em></label>
                </li> 
                <?php }else{ ?>
                 <li<?php if ($i->zma_default == 1) {?> class="select"<?php }?>>
                    <?php echo CHtml::link('修改本地址',array('/member/index/addaddress','aid'=>$i->zma_id),array('class'=>'modify f_r c_06c click','target'=>'_black'))?>
                    <?php if ($i->zma_default == 1) {?><span class="c_999 f_r">（默认地址）</span><?php }?>
                    <input class="radio" type="radio" name="order[address]" <?php if ($i->zma_default == 1) {?>checked="checked"<?php }?> value ="<?php echo $i->zma_id ?>"  />
                    <label><span><?php echo Area::model()->getAreaStrByFloorId($i->zar_id)?><?php echo $i->zma_address?></span> <em>( <?php echo $i->zma_name?> 收 )  <?php echo $i->zma_mob?></em></label>
                </li>        
                <?php }?>
                                                
                <?php
            }?>
         	</ul>
            <p class="btn_link f_r line_24"><?php echo l('<b class="ico ico_add"></b>新增收货地址','javascript:',array('class'=>'btn click','onclick'=>'addressshow()'))?><?php echo Chtml::link( '<b class="ico ico_manage"></b>管理收货地址',array('/member/index/addresses'),array('class'=>'btn','target'=>'_black')) ?></p>
        </div>            
        <?php } else {
            ?>
           <div class="no_address">还没有填写收货地址，现在去<?php echo l('添加收货地址','javascript:',array('class'=>'btn click','onclick'=>'addressshow()'))?></div>
        <?php } ?>         
        <div class="address_form add_form">
        	<div class="ico ico_close close" onclick="addresshide()"></div>
        	<ul>
            	<li><span class="tit"><em class="xing">*</em>收货人姓名：</span>
                    <input id="MemAddres_zma_name" class="t_ipt" type="text" name="MemAddres[zma_name]" maxlength="32" value="" />
                    <span id="MemAddres_zma_nameTip"></span>
                </li>
                <li>
                    <span class="tit"><em class="xing">*</em>省&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;份：</span>
                	<?php Area::getAreainfo('MemAddres',0,'clasname'); ?>
                    <span id="MemAddres_zar_idTip"></span>
                </li>
                <li>
                    <span class="tit"><em class="xing">*</em>地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;址：</span>
                    <input id="MemAddres_zma_address" class="t_ipt w_250" type="text" name="MemAddres[zma_address]" maxlength="100" value="" />
                   <span id="MemAddres_zma_addressTip"></span>
                <li>
                    <span class="tit"><em class="xing">*</em>手机：</span>
                    <input id="MemAddres_zma_mob" class="t_ipt ipt_bg" type="text" value="" name="MemAddres[zma_mob]" maxlength="11" />
                   <span id="MemAddres_zma_mobTip"></span>
                </li>
                <li>
                    <span class="tit">固定电话：</span>
                    <input id="MemAddres_zma_tel" class="t_ipt ipt_bg" type="text" value="" name="MemAddres[zma_tel]" maxlength="20" /> 
                    <span id="MemAddres_zma_telTip"></span>                   
                </li>               
                <li>
                    <span class="tit">邮政编码：</span>
                    <input id="MemAddres_zma_zip" class="t_ipt" type="text" name="MemAddres[zma_zip]" maxlength="6" value="" />
                    <span id="MemAddres_zma_zipTip"></span>
                </li>                
                <li><span class="tit"></span><button class="btn" type="submit" name="">保存收货人信息</button></li>
            </ul>
        </div>
    </div>
</div>
<!--确认收货地址  end-->
<!--确认订单信息  start-->
<div class="conf_order selected_pro">
	<div class="h"><h2 class="fs_14">确认订单信息</h2></div>
		<div class="hd">
    	<ul class="c_f">
            <li class="b">商品名称</li>
            <li class="c">单价(元)</li>
            <li class="d">数量</li>
            <li class="e">优惠</li>
            <li class="f">小计</li>
        </ul>
    </div>
    <div class="hr_18"></div>
    <table class="order_table" width="100%" cellspacing="0" cellpadding="0">
        <?php foreach( (array)$mycart as $key=>$c ){?>        
    	<tbody>
            <tr class="shop">
                <td colspan="5"><span class=""><?php echo F::setting('sitename') ?>客服</span><span class="mr10 d_n">店铺：<a class="c_06c" href="javascript:" title="">时尚男装品牌店</a></span><span class="d_n">卖家：<a class="c_06c" href="javascript:" title="">时尚男装品牌店</a></span><a class="ico_qq qq_online2" href="javascript:" title="和我联系">和我联系</a></td>
            </tr>
            <?php foreach ( (array)$c as $eid => $exp ) {?>

                    <?php if($eid == 'franking'){ //包邮?>
                    <?php foreach ( (array)$exp as $pid => $pro) {?>  
                        <tr>
                            <td class="pro">
                                <div class="c_img c_img60"><?php echo Tool::thumb($pro['pic_url'],50,50,$pro['title']) ?></div>
                                <p class="title_pro"><?php echo Chtml::link($pro['title'],array('/home/product/detail/','id'=>$pro['id']),array( 'calss'=> 'c_06c' ,'title'=>$pro['title'],'target'=>'_black')) ?></p>
                                <p class="other c_666"><span><?php echo $pro['options'][0]?></span><span><?php echo $pro['options'][1]?></span></p>
                            </td>
                            <td class="price fs_14" width="14%"><span><?php echo $pro['price'] ?></span></td>
                            <td class="amount" width="15%"><?php echo $pro['qty'] ?></td>
                            <td class="agio" width="15%"><span><?php echo OrdDiscount::getDiscountType($pro['active'])?></span></td>
                            <td class="integral" width="15%"><span class="fw_b fs_14 c_f60"><?php echo $pro['subtotal'] ?></span></td>
                        </tr> 
                    <?php }?> 
                         <tr>
                            <td colspan="5">
                                <div class="f_r" style="margin-right:20px;">运送方式：卖家包邮</div>
                            </td>
                        </tr>                                    
                    <?php }else{?>
                        <?php foreach ( (array)$exp as $pid => $pro) {?>
                                <?php foreach ( (array)$pro as $k => $m) {?>
                                <tr>
                                    <td class="pro">
                                        <div class="c_img c_img60"><?php echo Tool::thumb($m['pic_url'],50,50,$m['title']) ?></div>
                                        <p class="title_pro"><?php echo Chtml::link($m['title'],array('/home/product/detail/','id'=>$m['id']),array( 'calss'=> 'c_06c' ,'title'=>$m['title'],'target'=>'_black')) ?></p>
                                        <p class="other c_666"><span><?php echo $m['options'][0]?></span><span><?php echo $m['options'][1]?></span></p>
                                    </td>
                                    <td class="price fs_14" width="14%"><span><?php echo $m['price'] ?></span></td>
                                    <td class="amount" width="15%"><?php echo $m['qty'] ?></td>
                                    <td class="agio" width="15%"><span><?php echo OrdDiscount::getDiscountType($m['active'])?></span></td>
                                    <td class="integral" width="15%"><span class="fw_b fs_14 c_f60"><?php echo $m['subtotal'] ?></span></td>
                                </tr>                            
                                <?php }?>
                                <tr>
                                    <td colspan="5"> 
                                        <div class="f_r" style="margin-right:20px;">
                                            <ul>                                                
                                                <li>
                                                    <span class="tit">运送方式：</span>
                                                    <select id="<?php echo 'exp'.$pid?>" data="<?php echo $pid?>" name="order[ze_id]" class="s_ipt" onchange="exptype('<?php echo 'exp'.$pid?>')">
                                                        <?php
                                                         $sql = new CDbCriteria(array(
                                                            'condition' => 'zel_default=2 AND ze_id ='.$pid,                               
                                                        ));
                                                         $sql->group = 'zel_type'; 
                                                        $items = ExpressLog::model()->findAll($sql);
                                                        if ($items) {                        
                                                            foreach ( (array)$items as $i) {
                                                            $cookie = Yii::app()->request->getCookies();      
                                                            if($cookie['zel_type'.$pid]->value == $i->zel_type){
                                                                $select = "selected='selected'";
                                                            }else{
                                                                $select ='';
                                                            }
                                                                           
                                                        ?>

                                                        <?php if($i->zel_type==1){
                                                                        echo '<option value=1 '.$select.'>快递';
                                                                    }elseif($i->zel_type==2){
                                                                        echo '<option value=2 '.$select.'>EMS';
                                                                    }else{
                                                                        echo '<option value=3 '.$select.'>平邮';
                                                                    }
                                                            ?></option>
                                                        <?php
                                                            }
                                                            
                                                        } else {
                                                            ?>
                                                            <option value="0">暂无运费方式</option>
                                                        <?php } ?>
                                                    </select> 
                                                </li>
                                            </ul>
                                        </div>
                                    </td>
                                </tr>
                        <?php }?> 

                    <?php }?>
                             

            <?php }?>          
            
            <tr class="other_info">
            	<td colspan="5">                    
                	<div class="message f_l">
                    	<span class="tit">买家留言：</span><textarea class="t_area" name="order[zo_postscript]"></textarea>
                    </div>
                    <div class="fare f_l">
                    	<ul>
                            <?php if($activity_pro == 1){
                                if(F::setting('Multiplediscount') ==1){
                                ?>
                            <li>
                                    <span class="price f_r" id="favorable"></span>
                                    <span class="tit">商城优惠：</span>                                                                   
                                    <?php echo Chtml::dropDownList('order[favorable]','',array('1'=>'使用优惠券','2'=>'使用满就送'),array('class'=>'s_ipt','empty' => '选择优惠方式','onchange'=>"favorable($total,$fullsent)")) ?>                                    
                            </li>
                            <?php $listdata = MemTicket::model()->getmyticketlist($total); if(!empty($listdata)){?>
                        	<li class='d_n' id="favorable_ticket">
                                    <span class="price f_r" id="ticket">0.00</span>
                                    <span class="tit">优 惠 券 ：</span>                                                                   
                                    <?php echo Chtml::dropDownList('order[ticket]','',$listdata,array('class'=>'s_ipt','empty' => '选择优惠券','onchange'=>"orderticket($total)")) ?>                                    
                            </li>
                            <?php } ?>
                            <li  class='d_n' id="favorable_fullsent">                                
                                <span id="fullsent" class="price c_f60 f_r"><?php echo !empty($fullsent)?' - '.$fullsent:0 ?></span>
                                <span class="tit">满就送:</span>                                                    
                            </li>
                            <?php }}else{?>
                             <li>
                                    <span class="price f_r" id="favorable"></span>
                                    <span class="tit">商城优惠：</span>                                                                   
                                    <?php echo Chtml::dropDownList('order[favorable]','',array('1'=>'使用优惠券','2'=>'使用满就送'),array('class'=>'s_ipt','empty' => '选择优惠方式','onchange'=>"favorable($total,$fullsent)")) ?>                                    
                            </li>
                            <?php $listdata = MemTicket::model()->getmyticketlist($total); if(!empty($listdata)){?>
                            <li class='d_n' id="favorable_ticket">
                                    <span class="price f_r" id="ticket">0.00</span>
                                    <span class="tit">优 惠 券 ：</span>                                                                   
                                    <?php echo Chtml::dropDownList('order[ticket]','',$listdata,array('class'=>'s_ipt','empty' => '选择优惠券','onchange'=>"orderticket($total)")) ?>                                    
                            </li>
                            <?php } ?>
                            <li  class='d_n' id="favorable_fullsent">                                
                                <span id="fullsent" class="price c_f60 f_r"><?php echo !empty($fullsent)?' - '.$fullsent:0 ?></span>
                                <span class="tit">满就送:</span>                                                    
                            </li>
                            <?php } ?>
                            <li>                                
                            	<span id="exp_price" class="price c_f60 f_r"><?php echo $expprice?></span>
                            	<span class="tit">运费总计:</span>                                
                            </li>                            
                        </ul>
                    </div>
                </td>
            </tr>
            <tr class="shop_total d_n">
            	<td colspan="5">店铺合计（含运费）：<span class="total_price">130.00</span></td>
            </tr>            
        </tbody>
        
       <?php }?> 
    </table> 
    <div class="tab_foot c_f">
    	<!--<div class="integral"><span>您有可用商城积分500点，本次消费最多可用500点(抵用现金 <strong class="c_f60">5.00</strong> 元 )。</span><span>我要使用<input class="t_ipt" type="text" value="500" name="" maxlength="8" />点</span><span><strong class="ff_yh fs_18">-5.00</strong> 元</span></div>-->
        <div class="hr_18"></div>
        <div class="box">
            <div class="order_conf">               
                <p class="pay_price"><!--<span>可获商城积分：127点</span>--><span class="price">实付款：<strong class="fs_24 ff_yh c_f60" id="totalprice"><?php echo $total ?></strong> 元</span></p>
                <p class="address line_24"><span class="d_b"><strong>寄送至：</strong><?php echo $address['address']?></span><span><strong>收货人：</strong><?php echo $address['param']['zma_name']?> <?php echo $address['param']['zma_mob']?></span></p>
            </div>
            <div class="btn_link"><?php echo Chtml::link(' ','/cart/index',array('class'=>'btn btn_back'))?><button class="btn btn_settle" type="submit" name="" onclick="formsubmit(addressFrm)"></button></div>
        </div>
	</div>      
</div>
<!--确认订单信息  end--> 
</form>   
 <!-- 表单验证 -->
<script type="text/javascript" src="<?php echo Yii::app()->baseUrl;?>/js/formvalidata/formValidator-4.1.1.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->baseUrl;?>/js/formvalidata/formValidatorRegex.js"></script>
 <script>
    jQuery(document).ready(function($) {
        $.formValidator.initConfig({theme:"Default",formID:"address-form",
            onError:function(msg, obj){
                        alert(msg);
                        return false;
                    },
            onsuccess:function(){ return true; }
        });
    })
</script>
<script type="text/javascript" src="<?php echo Yii::app()->baseUrl;?>/js/formvalidata/cmpValidate.js"></script> 
<script type="text/javascript" src="<?php Yii::app()->baseUrl?>/js/cart.js"></script>
